unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm3 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;

implementation

{$R *.dfm}

function log10(x:real):real;
var rez:real;
begin
if x>0 then rez:=ln(x)/ln(10) else rez:=0;
log10:=rez;
end; //

function itisdigit(c:char):boolean;
begin
itisdigit := c in ['0','1','2','3','4','5','6','7','8','9','.',','];
end; // it is digit

Procedure DoCopyOfSplit;

var i1,o1:text;
    name_i1, name_o1 : string;
    CAS,
    SMILES,
    PA,
    PA2,
    s:string;
    j,
    k:integer;

    typeset,
    c:char;
    x,lnx:real;

begin

Randomize;

name_i1:=form3.Edit1.Text;
name_o1:=form3.Edit2.Text;

assign(i1,name_i1);reset(i1);
assign(o1,name_o1);rewrite(o1);

k:=0;
repeat k:=k+1;
readln(i1,s);                 //  showmessage(inttostr(k)+' '+s);
typeset:=s[1];

j:=1;
CAS:='';
repeat j:=j+1;
if s[j]<>' ' then CAS:=CAS+s[j];
until s[j]=' ';

SMILES:='';
repeat j:=j+1;
if s[j]<>' ' then SMILES:=SMILES+s[j];
until s[j]=' ';

PA:='';
repeat j:=j+1;
if j<=length(s) then
begin
//if s[j]='.' then s[j]:=',';
PA:=PA+s[j];
end;
until j>=length(s);

if PA='' then PA:='*';

//if k>420 then
//showmessage(inttostr(k)+' '+typeset+' '+CAS+' '+SMILES+' '+PA+' // '+inttostr(ord(PA[1])));

if PA<>'*' then
begin
x:=strtofloat(pa);
//lnx:=-log10(x);
//lnx:=-x;

lnx:= 5*(0.5-random);

pa2:=FloatToStrF(lnx,FFfixed,9,4);
writeln(o1,typeset,CAS,' ',SMILES,' ',lnx:9:3);

//showmessage(inttostr(k)+' '+typeset+' '+CAS+' '+SMILES+' '+FloatToStrF(lnx,FFfixed,9,4));

end;

until eof(i1);

closefile(i1);
closefile(o1);

showmessage('Operation is completed');
form3.close;

end; // DoCopyOfSplit

(*
procedure Tform3.Button1Click(Sender: TObject);
begin
DoCopyOfSplit;
// HALT;
end;
*)

procedure TForm3.Button1Click(Sender: TObject);
begin
DoCopyOfSplit;
end;

end.
